#ifndef SOCKET_H
#define SOCKET_H

#include "Includes.h"
#include "Utility.h"

class Socket {
	public:
		Socket(uint32_t ip, uint16_t prt); //connect to IPv4 on port
		Socket(uint8_t* ip, uint16_t prt); //connect to IPv6 on port; we can implement this later
		Socket(char* host, uint16_t prt); //connect to host; host can be DNS or IP address
		Socket(uint16_t port); //initialize to listen and accept connections on port
		Socket accept_connection();
		bool is_alive();
		int write(char* message, int length);
		int read(char* dest, int max_len);
		~Socket();
	private:
		int fd;
		uint16_t port;
		void init(char* host, uint16_t prt);
		Socket(int cfd); //used by accept_connection to initialize a socket that has been listened/accepted
};

#endif
